<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基本的路由界面</title>
</head>
<body>
<div id="app"></div>
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>
<script src="https://cdn.bootcss.com/vue-router/3.0.1/vue-router.js"></script>
<script>
  const NotFound ={template:`<p>page not found</p>`};
  const Home = {template:`<p>home page</p>`};
  const About = {template:'<p>about page</p>'};
  const routes = {
    '/':Home,
    '/about':About
  }
  //todo test
  var vm = new Vue({
    el:"#app",
    data:{
      currentRoute : window.location.pathname
    },
    computed:{
      ViewComponent(){
        return routes[this.currentRoute] || NotFound
      }
    },
    render(h) {
      return h(this.ViewComponent)
    }
  })
</script>
</body>
</html>